# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libtirpc
pkgver=1.3.4
pkgrel=0
pkgdesc="Transport Independent RPC library (SunRPC replacement)"
url="https://sourceforge.net/projects/libtirpc/"
arch="all"
license="BSD-3-Clause"
options="!check"
depends="$pkgname-conf"
depends_dev="
	bsd-compat-headers
	krb5-dev
	"
makedepends="
	$depends_dev
	autoconf
	automake
	libtool
	linux-headers
	"
subpackages="
	$pkgname-dbg
	$pkgname-static
	$pkgname-dev
	$pkgname-doc
	$pkgname-conf::noarch
	$pkgname-nokrb
	"
source="https://sourceforge.net/projects/libtirpc/files/libtirpc/$pkgver/libtirpc-$pkgver.tar.bz2
	soname-suffix.patch
	"

# secfixes:
#   1.3.2-r2:
#     - CVE-2021-46828

prepare() {
	default_prepare
	autoreconf -fi

	cp -r "$builddir" "$builddir-nokrb"
}

build() {
	_build SONAME_SUFFIX=''

	cd "$builddir-nokrb"
	_build --disable-gssapi SONAME_SUFFIX='-nokrb'
}

_build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconf=/etc \
		"$@"
	make
}

package() {
	make -C "$builddir-nokrb" install DESTDIR="$pkgdir"
	make install DESTDIR="$pkgdir"
}

conf() {
	pkgdesc="Configuration files for TI-RPC"

	amove etc/*
}

nokrb() {
	pkgdesc="$pkgdesc - without GSS-API/Kerberos"

	amove usr/lib/libtirpc-nokrb.*
}

sha512sums="
004e61b5853717324790c46cda5ff227d525909f189194ae72a1ec8f476ca35d7f4c1f03c0fbc690c1696d60a212675b09246dbe627fdbf1a9a47f5664e82b00  libtirpc-1.3.4.tar.bz2
912a2ad979cb7f41c4d2b558d2d213aaa02e904685ddddc43fbab4ee537543df5288d08b704102654e780d96175774496680384a4bfec37e7f1d7770922a63af  soname-suffix.patch
"
